home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / STDLIB.PAK / LEX_COMP.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  681b  |  28 lines

  1.  #include <algorithm>
  2.  #include <vector>
  3.  
  4.  using namespace std;
  5.  
  6.  int main(void)
  7.  {                            
  8.    int d1[5] = {1,3,5,32,64};         
  9.    int d2[5] = {1,3,2,43,56};
  10.    //
  11.    // Set up vector.
  12.    //
  13.    vector<int> v1(d1+0, d1+5), v2(d2+0, d2+5);    
  14.    //
  15.    // Is v1 less than v2 (I think not).
  16.    //
  17.    bool b1 = lexicographical_compare(v1.begin(),v1.end(),v2.begin(),v2.end());
  18.    //
  19.    // Is v2 less than v1 (yup, sure is).
  20.    //
  21.    bool b2 = lexicographical_compare(v2.begin(), v2.end(),
  22.                                      v1.begin(), v1.end(), less<int>());
  23.    cout << (b1 ? "TRUE" : "FALSE") << " "
  24.         << (b2 ? "TRUE" : "FALSE") << endl;
  25.  
  26.    return 0;
  27.  }
  28.